package com.chen.serlvet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 向域中修改数据
 */
@WebServlet("/servletB")
public class ServletB extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 向请求域中修改数据
        req.setAttribute("req", "reqMsgPlus");
        // 向会话域中修改数据
        req.getSession().setAttribute("session", "sessionMsgPlus");
        // 向应用的中修改数据
        getServletContext().setAttribute("application", "ApplicationMsgPlus");
    }
}
